Migrate server code to server/index.ts and simplify processes#1066
Merged
kentcdodds merged 4 commits intoepicweb-dev:mainfrom Dec 17, 2025
Merged
Migrate server code to server/index.ts and simplify processes#1066kentcdodds merged 4 commits intoepicweb-dev:mainfrom
server/index.ts and simplify processes#1066kentcdodds merged 4 commits intoepicweb-dev:mainfrom
Conversation
…structure, and streamline build and dev processes
…ion and documentation
kentcdodds
approved these changes
Dec 16, 2025
Member
kentcdodds
left a comment
There was a problem hiding this comment.
This is awesome! How is it done? I thought type stripping was only available without flags in node v25.
In any case, I absolutely love this if it works!
Contributor
Author
|
https://nodejs.org/en/learn/typescript/run-natively It was backported to Node 22 :) |
Member
|
That's just fantastic. Thanks! |
|
@kasperpeulen I think introducing the middleware to the This code: // no ending slashes for SEO reasons
// https://github.com/epicweb-dev/epic-stack/discussions/108
app.get('*', (req, res, next) => {
if (req.path.endsWith('/') && req.path.length > 1) {
const query = req.url.slice(req.path.length)
const safepath = req.path.slice(0, -1).replace(/\/+/g, '/')
res.redirect(302, safepath + query)
} else {
next()
}
})It should be moved before the Perhaps other middleware should be moved too (I'm not sure)? |
|
Also, mocks are not loaded during |
2 tasks
Contributor
Author
|
Fixed here @davidesigner |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When reviewing the code, I noticed custom build stuff that seemed unnecessary. It made me feel that react-router needs a lot of boilerplate, and custom stuff build scripts.
I looked at the best practices in react router:
https://github.com/remix-run/react-router-templates/tree/main/node-custom-server
And I concluded that the epic-stack does custom things that are not necessary.
This gets rid of:
For running the server files with ts without compilation or tsx, node 22.18 is needed, so I updated that requirement.
They could also easily be js files, as they contain very little types. That is what is done in the react-router-templates, but running TS through node for those 2 files, seems complety valid to me in modern code.
Test Plan
build, dev, dev:no-mocks, start and start:mocks commands should still work the same way
I tested all of them manually.
Checklist
Screenshots